package com.xzh.service.impl;

import com.xzh.dao.StatisticsMapper;
import com.xzh.service.StatisticsService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class StatisticsServiceImpl implements StatisticsService {
    private StatisticsMapper statisticsMapper;
    @Autowired
    public void setStatisticsMapper(StatisticsMapper statisticsMapper){
        this.statisticsMapper = statisticsMapper;
    }

    @Override
    public Map<String, Object> counts() {
        Map<String, Object> stats = new HashMap<>();

        // 获取各项统计数据
        stats.put("students", statisticsMapper.getStudentCount());
        stats.put("courses", statisticsMapper.getCourseCount());
        stats.put("teachers", statisticsMapper.getTeachersCount());
        stats.put("rating", statisticsMapper.getAverageRating());

        return stats;
    }
}
